import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCpList from '../resolves/getCpList.js';
import getCpDetail from '../resolves/getCpDetail.js';
import getDeviceList from '../resolves/getDeviceList.js'

import cpHtml from 'ngtemplate!html!../../../tpls/cp/cp.html';
import cpListHtml from 'ngtemplate!html!../../../tpls/cp/cp.list.html';

/**
 * CpRouter - config
 * 赛事模块路由设置
 */
CpRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function CpRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {

	//set router
    $stateProvider

		// 新建计时点
		.state('dashboard.race.cp', {
		    url: '/cp',
		    data: { 
		        pageTitle: '新建计时点' 
		    },
		    templateUrl: cpHtml,
		    controller: 'CpController as vm',
		    resolve: {
		    	authService: authService,
		    	getCpList: getCpList,
		    	getDeviceList: getDeviceList,
		    	loadPlugin: loadPluginFn([loadPlugin.blink, loadPlugin.icheck, loadPlugin.chosen])
		    }
		})

		// 计时点列表
		.state('dashboard.race.cplist', {
		    url: '/cp/list',
		    data: { 
		        pageTitle: '计时点列表' 
		    },
		    templateUrl: cpListHtml,
		    controller: 'CpListController as vm',
		    resolve: {
		    	authService: authService,
		    	getCpList: getCpList
		    }
		})

		// 编辑计时点
		.state('dashboard.race.cpedit', {
		    url: '/cp/edit?cp_id',
		    data: { 
		        pageTitle: '编辑计时点' 
		    },
		    templateUrl: cpHtml,
		    controller: 'CpEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getCpDetail: getCpDetail,
		    	getDeviceList: getDeviceList,
		    	loadPlugin: loadPluginFn([loadPlugin.blink, loadPlugin.icheck, loadPlugin.chosen])
		    }
		});

}

export default CpRouter; 